package com.baoxin.chenxixc4coach;

import android.os.Bundle;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.baoxin.chenxixc4coach.adapter.MyVideoAdapter;
import com.baoxin.chenxixc4coach.bean.Video;

import java.util.ArrayList;
import java.util.List;

public class MyVideoActivity extends BaseActivity {

    private RecyclerView recyclerView;
    private List<Video> videoList;
    private MyVideoAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_video);

        Toolbar toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        recyclerView = findViewById(R.id.recyclerview);
        videoList = new ArrayList<>();
        adapter = new MyVideoAdapter(this);
        initVideoData();
        adapter.setData(videoList);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setAdapter(adapter);
        recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
    }

    /**
     * 编辑
     *
     * @param view
     */
    public void onEdit(View view) {
    }

    /**
     * 上传视频
     *
     * @param view
     */
    public void onUpload(View view) {
    }

    private void initVideoData() {
        videoList = new ArrayList<>();

        Video video = new Video();
        video.setImg("URL");
        video.setTitle("倒车入库");
        video.setContent("指定时间停车入库的能力");
        video.setTime("03:27");


        Video video2 = new Video();
        video2.setImg("URL");
        video2.setTitle("坡道定点停车与起步");
        video2.setContent("离合器刹车之间半联动技巧");
        video2.setTime("03:27");

        Video video3 = new Video();
        video3.setImg("URL");
        video3.setTitle("侧方停车");
        video3.setContent("侧后方倒车入库的驾驶技巧");
        video3.setTime("03:27");

        Video video4 = new Video();
        video4.setImg("URL");
        video4.setTitle("倒车入库");
        video4.setContent("指定时间停车入库的能力");
        video4.setTime("03:27");

        Video video5 = new Video();
        video5.setImg("URL");
        video5.setTitle("倒车入库");
        video5.setContent("指定时间停车入库的能力");
        video5.setTime("03:27");

        Video video6 = new Video();
        video6.setImg("URL");
        video6.setTitle("倒车入库");
        video6.setContent("指定时间停车入库的能力");
        video6.setTime("03:27");


        videoList.add(video);
        videoList.add(video2);
        videoList.add(video3);
        videoList.add(video4);
        videoList.add(video5);
        videoList.add(video6);

    }
}
